<?php

$DeviceDetect = new uagent_info();

#swith theme device
if (!strpos($_SERVER['PHP_SELF'], 'admin')) {
    $DeviceTheme = 'true';
    $UseMobile = $this->config->get('config_mobile_enabled');
    $UseTablet = $this->config->get('config_tablet_enabled');
    if ((isset($_GET['DeviceTheme']) && $_GET['DeviceTheme'] == 'false') || (isset($_SESSION['DeviceTheme']) && $_SESSION['DeviceTheme'] == 'false' && !isset($_GET['DeviceTheme']))) {
        $_SESSION['DeviceTheme'] = 'false';
        $DeviceTheme = 'false';
    } elseif ((isset($_GET['DeviceTheme']) && $_GET['DeviceTheme'] == 'true') || (!isset($_GET['DeviceTheme']))) {
        $_SESSION['DeviceTheme'] = 'true';
        $DeviceTheme = 'true';
    }
    if ($DeviceTheme == 'true') {
        if ($UseMobile && ($DeviceDetect->isIphone || $DeviceDetect->isAndroidPhone || $DeviceDetect->isTierIphone || $DeviceDetect->isTierRichCss || $DeviceDetect->isTierGenericMobile)) {
            $_SESSION['DeviceTheme'] = 'true';
        } elseif ($UseTablet && $DeviceDetect->isTierTablet) {
            $_SESSION['DeviceTheme'] = 'true';
        }
    }
}